The invention relates to a method for representing a computer-modeled object, as defined in the preamble to claim 6, and an apparatus for executing the method, as defined in the preamble to claim 6.
In computer-graphics systems, bodies are usually simulated with grid models that are described by the spatial coordinates of the node points. To represent the polygon surfaces lying between the node points on a screen, the spatial coordinates of the node points are then converted from the three-dimensional coordinate system, for example through central projection, into a two-dimensional screen-coordinate system.
The image impression of the individual polygon surfaces is calculated in perspective, with the position and orientation of the polygon surface relative to the light sources and the predetermined observer""s location being considered in order to achieve the most natural image impression possible.
It is also known that the image impression should not be calculated all at once for the entire polygon surface, but the individual polygon surfaces should be divided into a plurality of pixels, and an image impression should be calculated individually for each pixel, so even a relatively crude grid model having large polygon surfaces can be used to attain a natural image impression. To this end, so-called shading methods are used to calculate the shadingxe2x80x94that is, the color or brightness gradationxe2x80x94within the polygon surface.
One shading method of this type is referred to as Phong shading. In this method, a data set is predetermined for each polygon surface; the local surface normal at the corner points of the polygon surface ensues from this set, so a curved polygon surface can also be realized, which further improves the degree of realism in the representation of an image. For each pixel within the polygon surface, the local surface normal resulting from the curvature of the polygon surface is interpolated from the predetermined corner-point normals. The image impression of the individual pixels is then calculated with the consideration of the local surface normal, according to a local illumination model.
While the above-described Phong shading advantageously permits a very natural image impression by taking into consideration the curvature of the individual polygon surfaces, the calculation is very complicated because the local illumination model for each pixel must be calculated.
An advantage of Phong shading, however, is the possibility of simulating a surface structure of the individual polygon surfaces without it being necessary to refine the grid model accordingly. For example, in representing a wood surface, it is possible to simulate the wood grain. For this purpose, a two-dimensional storage matrix (bump map) is provided, which defines the desired surface structure, with each storage location containing an inclination value that indicates how the local surface normal is inclined due to the surface structure; each pixel of the polygon surface is associated with a storage location of the storage matrix. In the calculation of the image impression of the individual pixels, first the associated storage location of the storage matrix is specified, and the inclination value representing the surface structure is read out. In the calculation of the image impression corresponding to the local illumination model, the interpolated local surface normal of the smooth polygon surface is not considered, but rather the local surface normal that is changed corresponding to the inclination value. This process utilizes the fact that the position of the pixel is not decisive for the image impression of a pixel of a relief-structured surface, but rather the change in the local surface normal caused by the surface structure is decisive.
However, the above-described simulation of a surface structure basically presupposes a shading method that interpolates the local surface normal individually for each pixel and calculates the image impression according to a local illumination model for each pixel, because the inclination of the local surface normal can only be considered in the calculation of the local illumination model. Up to now, therefore, so-called bump mapping has only been possible in connection with relatively complicated shading methods.
A significantly simpler shading method is known as Gouraud shading. In this instance, too, a data set is predetermined for each polygon surface, from which the spatial position of the local surface normals at the corner points of the polygon surface ensues. In contrast to the above-described Phong shading, however, the local illumination model is only calculated for the corner points of the polygon surface; in contrast, the image impression of the pixels within the polygon surface is interpolated from the image impression at the corner points of the polygon surface as a function of the position of the respective pixel within the polygon surface.
On the one hand, this saves calculation time in comparison to Phong shading, because the complicated calculation of the local illumination model is only effected at the corner points of the polygon surface, while the interpolation of the image impression for the individual pixels is considerably simpler in terms of the calculation effort.
On the other hand, the image impression in Gouraud shading is less natural than in the more complicated Phong shading, and it is not possible to simulate a surface structure (bump mapping) in the above-described manner.
It is therefore an object of the invention to provide a method of representing computer-modeled objects that also permits the simulation of a surface structure, with the least possible calculation effort, and without necessitating a corresponding refinement of the grid model. It is a further object of the invention to provide a corresponding apparatus for executing a method of this type.
These objects are accomplished by a method including the steps of: calculating at least one surface normal of a polygon surface from a first parameter set that predetermines the spatial position of individual polygon surfaces; calculating at least one global color value for the polygon surface as a function of the respective calculated surface normal; dividing the polygon surface into a plurality of pixels and calculating a respective coordinate set (X, Y, Z) which represents the spatial position of a respective pixel from the first parameter set; interpolating a first local color value for each individual pixel and the at least one calculated global color value of the polygon surface; individually addressing a first storage matrix with a plurality of storage locations for each individual pixel as a function of the respective coordinate set (X, Y, Z), each storage location of the first storage matrix containing an inclination value for simulating a surface structure of the polygon surface where the inclination value determines the inclination of the local surface normal due to the surface structure; reading out the inclination value for each individual pixel from the addressed storage location of the first storage matrix; calculating a second local color value that takes into consideration the influence of the surface structure on an image impression as a function of the read-out inclination value; and calculating a third local color value from the first local color value and the second local color value where the third local color value is the ultimate color value and serves in image representation for the individual pixels.
According to the invention, the apparatus for executing the method of representing a computer-modeled object that is simulated by a plurality of a adjacent polygon surfaces including an input for receiving the first parameter set, a second parameter set that determines a viewer""s perspective, and an illumination-data set which determines spatial position and irradiation properties of at least one light source; a first assembly for calculating at least one surface normal of the polygon surface from the first parameter set, a second assembly for calculating at least one global color value for a polygon surface as a function of the at least one calculated surface normal; a third assembly for dividing the polygon surface into a plurality of pixels and for calculating a respective coordinate set (X,Y Z) that represents the spatial position of a respective pixel; a fourth assembly for interpolating a first local color value for each individual pixel from the respective coordinate set (X, Y, Z) and the calculated at least one global color value for the polygon surface; a first storage matrix for simulating a surface structure, said storage matrix having a plurality of storage locations with each storage location containing an inclination value that determines the inclination of the at least one surface normal due to the surface structure; an addressing unit for addressing the first storage matrix individually for each pixel as a function of the coordinate set (X, Y, Z) of the respective pixel; a fifth assembly for calculating a second local color value, that takes into consideration the influence of the surface structure, as a function of the inclination value that has been read out of the first storage matrix; and a sixth assembly for mixing the first and second local values to form a third local color value which is subsequently written in to a screen memory.
The invention includes the technical teaching of combining the techniques of Gouraud shading and so-called bump mapping, which are known per se, in a method for representing computer-modeled objects.
The measures employed in the invention can be performed with both purely software-based measures and suitable special hardware. The hardware-based solution has the advantage that operations performed simultaneously in parallel assemblies yield significant time advantages.
If xe2x80x9cassembliesxe2x80x9d are discussed below, they may also involve functional groups, for example in the form of electrical circuits. It may also be that one and the same assembly or functional group consecutively performs different operations, as is generally the case in processor technology. As explained above, however, speed advantages can be attained if functional groups are active adjacently and in parallel.
In accordance with the invention, the image impression is calculated by a calculation unit that is a component of a superordinate graphics system, and obtains from this system all of the data that are necessary for calculating the image impression of a respective polygon surface.
Thus, the calculation unit of the invention obtains a first parameter set from the superordinate graphics system, which set represents the spatial position of the polygon surface to be represented. The first parameter set contains, for example, the spatial coordinate values of the corner points of the polygon to be represented, or the spatial coordinate values of the surface""s center of gravity, as well as the components of the normal vector of the polygon surface. The only decisive factor for the composition of the first parameter set is that the set unambiguously represent the spatial position of the polygon surface.
The calculation unit further receives a second parameter set, which determines the perspective of the viewer and defines, for example, the spatial coordinates of the viewer""s location or viewing direction. By changing this second parameter set, it is possible in a simple manner to change the viewer""s perspective of the objects to be represented, and thereby allow him to xe2x80x9cwanderxe2x80x9d through a spatial scene, for example.
The calculation unit further receives an illumination-data set from the superordinate graphics system, which set defines the optical properties of the illumination. The illumination-data set preferably includes the spatial coordinates of the light sources and their irradiation properties.
From these data, a first assembly of the calculation unit determines at least one surface normal for the respective polygon surface so that the image impression can subsequently be calculated according to a local illumination model. The first assembly preferably uses the first parameter set to calculate the local surface normals at all of the corner points of the respective polygon surface.
According to a local illumination model, a second assembly (shader) of the calculation unit subsequently uses the illumination-data set, the first parameter set and the local surface normals to calculate a color value that represents the image impression. The local illumination model is preferably calculated through, so that a two-dimensional interpolation of the color values within the polygon surface can be performed subsequently. Color value should be understood to be a general term here and hereinafter, and is not limited to chrominance values in the narrow sense, but also encompasses pure luminance values in a monochromatic representation.
To interpolate the color values in accordance with Gouraud shading, a third assembly divides the polygon surface into a plurality of pixels, with a coordinate set that indicates the position of the pixel within the polygon surface being calculated for each pixel.
A fourth assembly performs the actual interpolation for Gouraud shading individually for each pixel as a function of the position of the respective pixel within the polygon surface. In this way, a first local color value is calculated for each pixel, which value does not yet take into consideration any surface structure.
To define a surface structure, the calculation unit of the invention has a two-dimensional storage matrix, each of whose storage locations contains an inclination value that determines the inclination of the local surface normal resulting from the desired surface structure. A predetermined mapping function describes a fixed mapping of the polygon corner points onto the storage matrix addresses. Thus, each pixel of the polygon surface is allocated a storage location of the storage matrix, whose contents then determine the inclination of the local surface normal in this pixel.
The inclination vector, that is, the vector that must be added to the local surface normal of the smooth surface for creating the impression of the relief structure, or a xe2x80x9csubstitutexe2x80x9d surface normal as such, can be stored as an inclination value, for example. If this normal is already stored in normalized form, later angle calculations for determining the illumination components are simplified considerably. It is also possible to store a rotation matrix that defines the rotation of the local surface normal as an inclination value. This is particularly advantageous, because the length of the local surface normal is not changed by a rotation.
The relief structure itself is preferably not stored as a relief in the storage matrix; instead, the inclination of the local surface normal resulting from the course of the surface is stored. The local surface normal that is inclined due to the relief structure can therefore advantageously be calculated relatively quickly and with little calculation effort.
In this connection, it is decisive that the relief value be exclusively dependent on the position of the pixel within the polygon surface, but not on the global position of the pixel or the spatial position of the polygon surface. This is necessary because otherwise the relief structure appearing on the polygon surface would xe2x80x9cmigratexe2x80x9d on the surface during a movement of the polygon. The storage matrix is therefore addressed individually for each pixel as a function of the respective coordinate set, with the addressing unit ensuring that the association of the individual pixels with the storage locations of the storage matrix is independent of a possible change in the position of the polygon surface.
The surface structure defined by the storage matrix is actually taken into consideration by a fifth assembly of the calculation unit, which reads the inclination value of the respective pixel out of the storage matrix and, in connection with a vector that represents the illumination situation and contains information about the relationship between the point of sight and the light source, the assembly calculates a second local color value that takes into consideration the surface structure.
The vector representing the illumination situationxe2x80x94for example, the so-called half-vectorxe2x80x94must be available as additional information (in the described version, 1xc3x97 per polygon), calculated in advance, transformed into the bump-coordinate system and transmitted. In the calculation of the illumination model at the polygon corners for Gouraud shading, such a vector is already necessary and calculated; in the use of another illumination equation, an adequate vector is necessary.
With the transformation of the half-vector into the bump-coordinate system, the position of the polygon in space is xe2x80x9chidden,xe2x80x9d and the transformed half-vector contains all of the information for performing xe2x80x9cbump mapping.xe2x80x9d
This procedure avoids a complicated transformation of each individual storage matrix element into the illumination-coordinate system; after only one transformation per polygon has been performed, the local second color value can be calculated in the bump-coordinate system. The illumination is calculated in a specific coordinate system, referred to as a world system (WC). The object to be viewed is described in a suitable model-coordinate system (MC). The coordinate system of storage matrix entries is referred to as a texture bump system (TB). A matrix M (mapping matrix) describes the mapping of a vector v of the TB according to MC (given or determined from the association of object points⇄bump address). A matrix P (model matrix) describes the mapping of a vector v of the MC according to WC. H is the half-vector. In this case:
vWCP*vMC
vMC=M*vTB
vWC=P*M*vTB=A*vTB
and therefore:
HTB=Axe2x88x921*HWC; HTBN=HTB/∥HTB∥
A sixth assembly then calculates the ultimate local color value for the subsequent actuation of a screen or another output unit by mixing the first and second local color values.
The invention thus permits the simulation of a surface structure in connection with a simple Gouraud-type shading algorithm, so a surface structure can be represented, even in rapid moved-image representations, because of the savings of calculation time.
In an advantageous variation of the invention, which is significant enough to merit protection, the storage matrix directly contains the local surface normal in the respective pixel. In contrast to the conventional methods of bump mapping, no calculation-intensive interpolation of the local surface normal is necessary for the representation, because the storage matrix (bump map) directly contains the local surface normal. To determine the local surface normal in the respective pixel, therefore, it is merely necessary to determine the associated storage location of the storage matrix from the coordinate set of the pixel, and correspondingly address the storage matrix, so the local surface normal can be read out.
In one embodiment of this variation, the local color values for the individual pixels are calculated according to the above-described Phong shading method, which, because of the fast calculation of the local surface normal, is possible without a time-consuming interpolation using the corner-point normals.
In another, contrasting embodiment of this variation, the local color values are calculated for the individual pixels according to the Gouraud shading methodxe2x80x94as described abovexe2x80x94through interpolation of the color values that have been calculated for the corner points from the local illumination model, while the local surface normals that have been read out of the storage matrix only serve in a later addition of Phong illumination components.
In accordance with another, contrasting embodiment of this variation, the local surface normal that has been read out of the storage matrix serves in addressing a further storage matrix (reflection map), which simulates an envelope surface around the respective pixel. Such reflection maps are known to one of skill in the art; the reflection map is addressed, with the assumption of specular reflection, by the reflected eye vector, whereas, in diffuse reflection, the local surface normal directly addresses the reflection or environment map.
Moreover, the above-described, fast determination of the local surface normal also offers the option of using ray-tracing methods.
As described above, the body or surface intended to be shown on the screen is simulated in the computer as a grid model. The surface therefore comprises numerous polygon surfaces whose spatial position is defined by the spatial coordinates of the node points of the grid model. Triangles are preferably used as polygon surfaces, which offers the advantage that the surface normal of a triangle is unambiguously defined by the spatial coordinates of the corner points, because three points always lie in one plane, while in polygons having more than three corner points, it is possible that the corner points do not lie exactly in one plane, so the surface normal is not defined exactly.
The above-described method is not limited to a monochromatic representation. Rather, the method can be executed successively or in parallel for a plurality of colorsxe2x80x94preferably the primary colors. In this instance, a color-dependent reflection or absorption behavior of the surface can also be taken into consideration.
In an advantageous embodiment of the invention, the apparatus is configured as an integrated circuit in a processor system, or as an independent processor whose input receives a parameter set that, among other things, determines the spatial position of a polygon surface. At the output, the apparatus outputs the screen coordinates of individual pixels of the polygon surface, as well as the brightness value of the pixels. The circuit can thus be advantageously incorporated into existing computer-graphics systems.